#include"TaskMgr.h"
#include"TTime.h"
#include<iostream>
#include<thread>
#include<chrono>

using namespace tmms::base;

void task(){
    TaskPtr task1 = std::make_shared<Task>([](const TaskPtr& task){
        std::cout<<"this is task 11 interval:"<<1000<<"Now:"<<TTime::NowMS()<<std::endl;
        task->Restart();
    },1000);
    TaskPtr task2 = std::make_shared<Task>([](const TaskPtr& task){
        std::cout<<"this is task 22 interval:"<<1000<<std::endl;
        task->Restart();
    },1000);
    TaskPtr task3 = std::make_shared<Task>([](const TaskPtr& task){
        std::cout<<"this is task 33 interval:"<<500<<std::endl;
        task->Restart();
    },500);
    TaskPtr task4 = std::make_shared<Task>([](const TaskPtr& task){
        std::cout<<"this is task 44 interval:"<<5000<<std::endl;
        task->Restart();
    },5000);

    sTaskMgr->Add(task1);
    sTaskMgr->Add(task2);
    sTaskMgr->Add(task3);
    sTaskMgr->Add(task4);
}

// int main(){
//     task();
//     while(1){
//         sTaskMgr->onWork();
//         std::this_thread::sleep_for(std::chrono::milliseconds(50));
//     }

//     return 0;
// }